var newCourseList = [
  {
    id: 511021,
    title: "React for Beginners",
    coverPng:
      "https://res.cloudinary.com/dohtkyi84/image/upload/v1481226146/react-cover.png",
    rating: 5,
  },
  {
    id: 511022,
    title: "Vue2 for Beginners",
    coverPng:
      "https://res.cloudinary.com/dohtkyi84/image/upload/v1481226146/react-cover.png",
    rating: 5,
  },
  {
    id: 511023,
    title: "Angular2 for Beginners",
    coverPng:
      "https://res.cloudinary.com/dohtkyi84/image/upload/v1481226146/react-cover.png",
    rating: 5,
  },
  {
    id: 511024,
    title: "Webpack for Beginners",
    coverPng:
      "https://res.cloudinary.com/dohtkyi84/image/upload/v1481226146/react-cover.png",
    rating: 4,
  },
];

// newCourseList.forEach((course) => {
// 	idAndTitle.push({ id: course.id, title: course.title });
// });
Array.prototype.Map = function (callback) {
  let arr = [];
  this.forEach((item, index) => {
    console.log("ca,", callback(item, index));
    arr.push(callback(item, index));
  });
  return arr;
};
let idAndTitle = newCourseList.Map((item) => {
  return { id: item.id, title: item.title }; // 这里如果直接是一个值，确实不用return,但是是一个对象，就需要return
});
// console.log("idAndTitle", idAndTitle);

// console.log(
//   "%c [  ]-48",
//   "font-size:13px; background:pink; color:#bf2c9f;",
//   newCourseList
// );
Array.prototype.Filter = function (callback) {
    let arr = [];
    this.forEach((item, index) => {
        if (callback(item, index)) {
            arr.push(item);
        }
    })
    return arr
}
const id = newCourseList.Filter((item) => item.rating === 4);
console.log("id", id);
